package jpaperwork.meta.descriptor;

public abstract class TypeVisitor {
    public final Object visit(Type type){
        if (type instanceof Form) {
            return visitForm((Form) type);
        }
        if (type instanceof Flat) {
            return visitFlat((Flat) type);
        }

        if (type instanceof Aggregation) {
            return visitAggregation((Aggregation) type);
        }
        if (type instanceof Polymorphism) {
                return visitPolymorhpism((Polymorphism) type);
        }
        throw new RuntimeException("Unkown type " + type);
    }

    protected abstract Object visitForm(Form form);

    protected abstract Object visitPolymorhpism(Polymorphism polymorphism);

    protected abstract Object visitAggregation(Aggregation aggregation);    

    protected abstract Object visitFlat(Flat flat);
}
